function writeOutDoubleclickTags(){
	$('#ads').empty();
	$('#waiting').show();
	chrome.tabs.getSelected(null, function(tab) {
		if(tab.status!='loading')
			doWriting(tab.id);
		else
			chrome.tabs.onUpdated.addListener(doWriting);
	});
}

/*
function highlightAd(){	
	chrome.tabs.sendRequest(tabId, {action: 'highlight'},function(){});
}

function unHighlightAd(){	
	chrome.tabs.sendRequest(tabId, {action: 'unhighlight'},function(){});
}
*/

function doWriting(tabId,changeInfo,tab){
	chrome.tabs.sendRequest(tabId, {action: 'getDoubleClickTags'}, function(response){
		$.each(response.action,function(idx,elem){
			$('#ads').append('<li class="ad">');
			$('#ads').append(elem);
			$('#ads').append('</li>');
		});

		$("li").hover(
		  function () {
			$(this).append($("<span> ***</span>"));
		  }, 
		  function () {
			$(this).find("span:last").remove();
		  }
		);
		
		
		$("li.fade").hover(function(){$(this).fadeOut(100);$(this).fadeIn(500);});
		
		
	});
	
	$('#waiting').hide();
}